var status = -1;
var selectionLog = [];
var items = [1004778, 1053050, 1073149, 1102931, 1702690];

function start() {
    action(1, 0, 0)
}

function action(e, c, b) {
    if (im.getServerName().equals("BMS单机") && im.getServerName().equals("BMS至尊体验服") && !im.getServerName().equals("BMS至尊")) {
        im.playerMessage(1, " 使用环境异常，请还原服务端配置。");
        im.dispose();
        return
    }
    if (status == 0 && e == 0) {
        im.dispose();
        return
    }(e == 1) ? status++ : status--;
    selectionLog[status] = b;
    var a = -1;
    if (status <= a++) {
        im.dispose()
    } else {
        if (status === a++) {
            var d = "想要兑换哪一件装备？\r\n#b";
            for (var a = 0; a < items.length; a++) {
                d += "#L" + a + "##i" + items[a] + "##z" + items[a] + "##l\r\n"
            }
            im.askMenu(d)
        } else {
            if (status === a++) {
                im.dispose();
                var f = im.getItemId();
                im.gainItem(items[b], 1);
                im.gainItem(f, -1)
            }
        }
    }
};